<?php
// ----- >> Extends From Template
class thisPDF extends PDF{
	function Header(){}
	function Footer(){}
}


// ----- >> Init
$fpdf = new thisPDF('P','mm','A4');

foreach ($listKaryawan as $key => $value) {
	$fpdf->AddPage();
	$fpdf->SetLeftMargin(8);

	$fpdf->Ln(0);
	$ln_header_y_top	= $fpdf->GetY();


	// ----- >> Header
	$fpdf->Ln(2);

	$fpdf->SetFont('Arial','B',14);
	$fpdf->Cell(0,5,$judul,0,1,'C');

	$fpdf->Ln(10);


	// ----- >> Data Master
	$fpdf->SetFont('Arial','',10);
	$fpdf->Cell(30,5,"NIK",0,0,'L');
	$fpdf->Cell(2,5,":",0,0,'L');
	$fpdf->Cell(60,5,$value->id_karyawan_fk,0,0,'L');

	$fpdf->Cell(30,5,"",0,0,'L');
	$fpdf->Cell(2,5,"",0,0,'L');
	$fpdf->Cell(20,5,"",0,1,'L');


	$fpdf->SetFont('Arial','',10);
	$fpdf->Cell(30,5,"Nama",0,0,'L');
	$fpdf->Cell(2,5,":",0,0,'L');
	$fpdf->Cell(60,5,$value->nama_karyawan,0,1,'L');

	$fpdf->Cell(30,5,"Periode Gaji 13",0,0,'L');
	$fpdf->Cell(2,5,":",0,0,'L');
	$fpdf->Cell(20,5,$value->nama_periode_thr,0,1,'L');	

	// Detail Gaji 13
	$detail_g13 = json_decode($this->G13->GetDetailJSON($value->id_g13_pk));
	$kode_bayar = $detail_g13->rows;
	$total = $detail_g13->footer;

	// ----- >> Tabel
	$fpdf->Ln(10);
	$fpdf->SetFont('Arial','B',10);
	$fpdf->Cell(60,5,'Nama Bayar',1,0,'C');
	$fpdf->Cell(35,5,'Pendapatan (A)',1,0,'C');
	$fpdf->Cell(30,5,'Potongan (B)',1,0,'C');
	$fpdf->Cell(45,5,'Kontribusi Koperasi (C)',1,1,'C');
	$fpdf->SetFont('Arial','',8);
	foreach ($kode_bayar as $key2 => $value2) {
		$fpdf->Cell(60,5,$value2->nama_kode_bayar,1,0,'L');
		$fpdf->Cell(35,5,numberDisplay($value2->pendapatan),1,0,'R');
		$fpdf->Cell(30,5,numberDisplay($value2->potongan),1,0,'R');
		$fpdf->Cell(45,5,numberDisplay($value2->kontribusi_koperasi),1,1,'R');
	}


	// Total
	$fpdf->Ln(2);
	$fpdf->SetFont('Arial','B',10);
	foreach ($total as $key3 => $value3) {
		$fpdf->Cell(60,5,strip_tags($value3->nama_kode_bayar),1,0,'L');
		$fpdf->Cell(35,5,numberDisplay($value3->pendapatan),1,0,'R');
		$fpdf->Cell(30,5,numberDisplay($value3->potongan),1,0,'R');
		$fpdf->Cell(45,5,numberDisplay($value3->kontribusi_koperasi),1,1,'R');
	}
}




echo $fpdf->Output('Slip_gaji13.pdf', 'I');
exit();
?>